<?php

namespace App\Criteria;

use App\Http\Controllers\AppBaseController;
use Prettus\Repository\Contracts\CriteriaInterface;
use Prettus\Repository\Contracts\RepositoryInterface;
use Zend\Diactoros\Request;

/**
 * Class RolesCriteria
 * @package namespace App\Criteria;
 */
class UserParkCriteria implements CriteriaInterface
{
    /**
     * 按照角色筛选
     *
     * @param                     $model
     * @param RepositoryInterface $repository
     *
     * @return mixed
     */
    public function apply($model, RepositoryInterface $repository)
    {
        $controller = new AppBaseController();
        $parks = $controller->getParkCodes($controller->getUserParks());
        $model = $model->whereIn('park_code',$parks);
        return $model;

    }
}
